<script>
	export default {
		onLaunch() {
			uni.getSystemInfo({
				success: function(info) {
					let iStatusBarHeight = Number(info.statusBarHeight) || 0;
					uni.setStorageSync('stausBarHeight', iStatusBarHeight);
				}
			});
			// #ifdef H5
			let ClientRect ={};
			let ClientRectTop = Number(ClientRect.top) || 24;
			let ClientRectHeight = Number(ClientRect.height) || 32;
			uni.setStorageSync('ClientRectTop', ClientRectTop);
			uni.setStorageSync('ClientRectHeight', ClientRectHeight);
			// #endif
			
			// #ifdef MP-WEIXIN
			/*获取右上角胶囊信息->微信小程序、支付宝小程序、百度小程序、抖音小程序、QQ小程序  */ 
			let ClientRect = wx.getMenuButtonBoundingClientRect();
			let ClientRectTop = Number(ClientRect.top) || 24;
			let ClientRectHeight = Number(ClientRect.height) || 32;
			uni.setStorageSync('ClientRect', ClientRect);
			uni.setStorageSync('ClientRectTop', ClientRectTop);
			uni.setStorageSync('ClientRectHeight', ClientRectHeight);
			this.wxversionupdate();
			// #endif
		},
		methods: {
			onShareTimeline(res) {
				return {
					title: 'e驾考',
					imageUrl: "/static/logo.png"
				}
			},
			onShareAppMessage(res) {
				return {
					title: 'e驾考',
					path: '/pages/tabbar/home',
					imageUrl: "/static/logo.png"
				}
			},
			wxversionupdate(){  // 微信小程序更新
				const updateManager = uni.getUpdateManager();
				updateManager.onCheckForUpdate(res => {
					if (res.hasUpdate) {
						uni.showModal({
							content: '新版本已经准备好，是否重启应用？',
							showCancel: false,
							confirmText: '确定',
							success: res => {
								if (res.confirm) {
									updateManager.onUpdateReady(function(res) {
										updateManager.applyUpdate();
									});
									updateManager.onUpdateFailed(res => { // 新版本下载失败的回调
										// 新版本下载失败，提示用户删除后通过冷启动重新打开
										uni.showModal({
											content: '下载失败，请删除当前小程序后重新打开',
											showCancel: false,
											confirmText: '知道了'
										})
									})
								}
							}
						})
					}
				})
			}
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	@import './public/public.css';
	page{
		max-width: 800rpx;
		margin: auto;
		background: #F7F7F7;
		padding-bottom: 50rpx;
	}
	/* 让图片更清晰，仅限image标签 */
	image{
		image-rendering: -moz-crisp-edges;
		image-rendering: -o-crisp-edges;
		image-rendering: -webkit-optimize-contrast;
		image-rendering: crisp-edges;
		-ms-interpolation-mode: nearest-neighbor;
	}
</style>
